﻿namespace MyTRCP.Common.MyProtocol
{
    public class LinkControlResponsePayload : BitWalkableObj
    {
        public LinkControlResponseStatusCodeEnum StatusCode { get; set; }
        public byte[] Data { get; set; } = [];
        public LinkControlResponsePayload() { }
        public LinkControlResponsePayload(LinkControlResponseStatusCodeEnum statusCode, byte[] data)
        {
            StatusCode = statusCode;
            Data = data;
        }
        public LinkControlResponsePayload(byte[] data) : base(data) { }
        public override BitWalker ReadFromBitWalker(BitWalker bw)
        {
            StatusCode = (LinkControlResponseStatusCodeEnum)bw.ReadBits(8);
            Data = bw.ReadBytesToEnd();
            return bw;
        }

        public override BitWalker WriteToBitWalker(BitWalker bw)
        {
            return bw.WriteBits((byte)StatusCode, 8).WriteBytes(Data);
        }
    }
}
